package com.wandian.message.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mylib.libcore.AppContext;
import com.mylib.libcore.utils.UIUtils;
import com.wandian.message.R;
import com.wandian.message.bean.SysMessageBean;

/**
 * @author Administrator
 * @date 2019/12/16-13:32
 * @description 消息适配器
 **/
public class MessageRecycleAdapter extends BaseQuickAdapter<SysMessageBean, BaseViewHolder> {

    public MessageRecycleAdapter(int layoutResId) {
        super(layoutResId);
    }


    @Override
    protected void convert(BaseViewHolder helper,SysMessageBean item) {

        ImageView iv_message_red = helper.getView(R.id.iv_message_red);
        String read_message_ids = AppContext.getInstance().getAppPreferencesHelper().getKeyValue("read_message_ids");
        if(!UIUtils.isEmpty(read_message_ids) && read_message_ids.contains(item.getId()+"=")){
            iv_message_red.setVisibility(View.GONE);
        }else {
            iv_message_red.setVisibility(View.VISIBLE);
        }

        TextView tv_message_title = helper.getView(R.id.tv_message_title);
        tv_message_title.setText(item.getNoticeTitle()+"");
        TextView tv_message_content = helper.getView(R.id.tv_message_content);
        tv_message_content.setText(item.getNoticeContent()+"");
        TextView tv_message_time = helper.getView(R.id.tv_message_time);
        tv_message_time.setText(item.getCreateTime()+"");
    }

}
